package util;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.CommonDataSource;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class JDBCUtil {
    private static DataSource ds;

    static {
        ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
        ds=comboPooledDataSource;
    }

    /**
     * 获取链接池对象
     */
    public static DataSource getDataSource(){
        return ds;
    }
    /**
     * 获取连接Connection
     */
    public static Connection getConnection() throws SQLException {
        Connection connection = ds.getConnection();
        return connection;
    }
}
